import request from '@/utils/request'
import type { roleData, roleListRes } from './type'

enum API {
    ROLE_UTL = '/admin/acl/role/',
    ROLE_ALL_URL = '/admin/acl/permission/toAssign/',
    SETPERMISTION_URL = '/admin/acl/permission/doAssign/?'
}

export const reqgetRoleList = (page:number,limit:number,roleName?:string) => {
    if(roleName) {
        return request.get<any,roleListRes>(API.ROLE_UTL+`${page}/${limit}?roleName=${roleName}`)
    }else {
        return request.get<any,roleListRes>(API.ROLE_UTL+`${page}/${limit}`)

    }
}
export const reqgetRoleAcl = (id:number) => request.get<any,roleData>(API.ROLE_ALL_URL+`${id}`)
export const reqUpdateRoleAcl = (id:number,permissionId:number[]) => request.post<any,any>(API.SETPERMISTION_URL + `roleId=${id}&permissionId=${permissionId}`)